package com.jie.ribbonconsumer.controller;

import com.jie.ribbonconsumer.domain.User;
import com.jie.ribbonconsumer.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jie
 * @date 2019/8/1 -9:38
 */
@RestController
public class ConsumerController {

    private final org.jboss.logging.Logger logger = org.jboss.logging.Logger.getLogger(getClass());
    @Autowired
    HelloService helloService;

    @GetMapping("/ribbon-consumer")
    public String helloConsumer() throws InterruptedException {
        long start = System.currentTimeMillis();
        String s = helloService.helloService();
        long end = System.currentTimeMillis();
        logger.info("执行花费了:" + (end - start));
        return s;
    }

   @GetMapping("users/{id}")
    public User user(@PathVariable Integer id){
        return  helloService.getUserById(id);
   }

}
